<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script>
  // 1. 建立与服务器之间的长连接
  var ws = new WebSocket('ws://127.0.0.1:7788/imserver/1');
  // 2. 连接成功后的回调函数
  ws.onopen = function(e) {
    console.log('连接WebSocket');
  }
  // 3.接受推送消息回调
  ws.onmessage = function(e) {
    console.log(e.data,'---------');
  }
  // 4.连接关闭
  // setTimeout(function(){
    
  // },1000);
  // ws.onclose = function() {
  //   console.log('断开连接');
  // }
</script>
</html>